package jifenbao.com.jifenbao;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/5/30 0030.
 */
public class WalletActivity extends Activity{
    private ListView walletListView;
    private View footerlogo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wallet);

        walletListView = (ListView)findViewById(R.id.wallet_listview);
        updateWallet();
    }

    public void updateWallet(){
//        footerlogo = View.inflate(this,R.layout.activity_footer_logo,null);
//        AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT);
//        footerlogo.setLayoutParams(lp);
//        walletListView.addFooterView(footerlogo);

        List<Map<String,Object>> data = new ArrayList<>();
        //int[] logos = {R.mipmap.portrait,R.mipmap.shop_logo_2,R.mipmap.shop_logo_3};
        Map<String, Object> map1 = new HashMap<>();
        map1.put("shop_logo",R.mipmap.portrait);
        map1.put("shop_name","卡路里先生");
        map1.put("points_count","25800");
        map1.put("redeem_cases","4");
        map1.put("coupon_count","3");
        data.add(map1);

        Map<String, Object> map2 = new HashMap<>();
        map2.put("shop_logo",R.mipmap.shop_logo_2);
        map2.put("shop_name","青柠觉醒饮品");
        map2.put("points_count","800");
        map2.put("redeem_cases","4");
        map2.put("coupon_count","3");
        data.add(map2);

        Map<String, Object> map3 = new HashMap<>();
        map3.put("shop_logo",R.mipmap.shop_logo_3);
        map3.put("shop_name","猫猫和毛毛的美味猫屎咖啡");
        map3.put("points_count","240");
        map3.put("redeem_cases","4");
        map3.put("coupon_count","5");
        data.add(map3);

        SimpleAdapter couponAdapter = new SimpleAdapter(this,data,R.layout.activity_wallet_item,
                new String[]{"shop_logo","shop_name","points_count","redeem_cases","coupon_count"},
                new int[]{R.id.shop_logo,R.id.shop_name,R.id.points_count,R.id.redeem_cases,R.id.coupon_count});
        walletListView.setAdapter(couponAdapter);
    }
}
